package com.it.sun.esaychat.user.controller;


import com.it.sun.easychat.model.util.ResultHelper;
import com.it.sun.easychat.model.vo.LoginVO;
import com.it.sun.easychat.model.vo.ResultVO;
import com.it.sun.easychat.model.vo.UserPasswordVO;
import com.it.sun.esaychat.user.entity.UserEntity;
import com.it.sun.esaychat.user.service.IUserServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;



/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sunmannian
 * @since 2020-05-24
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户服务类",value = "用户服务类")
public class UserController {

    @Autowired
    private IUserServices userServices;

    @ApiOperation(value = "新增用户")
    @PostMapping()
    public ResultVO<Void> save(@RequestBody UserEntity user) {
        userServices.insert(user);
        return ResultHelper.success();
    }

    @ApiOperation(value="修改密码")
    @PutMapping()
    public ResultVO<Void> update(@RequestBody UserEntity user) {
        userServices.insert(user);
        return ResultHelper.success();
    }

    @ApiOperation("用户登录接口")
    @PostMapping("/login")
    public ResultVO<Void> login(@RequestBody LoginVO loginVO){
        return null;
    }

    @ApiModelProperty("修改用户密码")
    @PutMapping("/password")
    public ResultVO<Void> changePassword(@RequestBody UserPasswordVO userPasswordVO){
        userServices.changePassword(userPasswordVO);
        return ResultHelper.success();
    }
}

